cmake_minimum_required(VERSION 3.0...3.28)
project(coroutine)

set(CMAKE_CXX_STANDARD 17)
add_definitions(-DFREESTANDING)

set(OS_DEP_LIB "")
if (OS MATCHES LINUX)
    set(OS_DEP_LIB pthread)
    add_definitions(-DLINUX)
elseif (OS MATCHES QNX)
    set(OS_DEP_LIB regex)
    add_definitions(-DQNX)
endif ()
message(STATUS ${OS_DEP_LIB})

enable_language(ASM)

include_directories(src/arch/${ARCH}/include)
include_directories(src/arch/common)
include_directories(src/arch/common/include)
include_directories(src/coroutine)

set(UCONTEXT_SRCS ${UCONTEXT_SRCS} src/arch/${ARCH}/getcontext.S)
set(UCONTEXT_SRCS ${UCONTEXT_SRCS} src/arch/${ARCH}/setcontext.S)
set(UCONTEXT_SRCS ${UCONTEXT_SRCS} src/arch/${ARCH}/swapcontext.S)
aux_source_directory(src/arch/${ARCH} UCONTEXT_SRCS)

add_library(context ${UCONTEXT_SRCS})

add_executable(coroutine src/example/main.cpp)
target_link_libraries(coroutine PUBLIC context ${OS_DEP_LIB})

aux_source_directory(src/unitest UNITEST_SRCS)
add_executable(unitest ${UNITEST_SRCS})
target_link_libraries(unitest PUBLIC context ${OS_DEP_LIB} gtest gtest_main)
#target_link_directories(unitest PUBLIC /home/calmcar/public_project/vave_vision_a2/libs/gtest/lib)
#target_include_directories(unitest PUBLIC /home/calmcar/public_project/vave_vision_a2/libs/gtest/include)
